/**
 * 
 */
package skewreduce.framework.planner;

import java.util.List;

import org.apache.hadoop.conf.Configurable;
import org.apache.hadoop.conf.Configuration;

import skewreduce.lib.ITuple;
import skewreduce.lib.Partition;


/**
 * cost estimation function supporting incremental update.
 * @author yongchul
 *
 */
public abstract class CostEstimator implements Configurable {
	protected Configuration conf;
	protected double sigma;
	
	@Override
	public final Configuration getConf() {
		return conf;
	}
	
	@Override
	public void setConf(Configuration conf) {
		this.conf = conf;
		this.sigma = conf.getFloat("skewreduce.planner.sampleRate", 0.0f);
	}
	
	public double getSampleRate() { return sigma; }
	
	public abstract void init(Partition p,int sz);
	public abstract void update(ITuple data);
	public void update(List<? extends ITuple> data) {
		for ( ITuple t : data )
			update(t);
	}
	public abstract double getCost();
	public void free() {
	}
}